<script>
/**
 * @desc
 * 单个旅游路线的'行程路线'进入;
 * 日程详情描述
 */

import { mapState } from 'vuex'

export default {
  name: 'route-detail',
  data: () => ({ index: 0 }),
  computed: {
    ...mapState('Order', { routes: state => state.currTravelDetail.schedules }),
    item() {
      return this.routes.length &&
        this.routes[this.index].scheduleIntros &&
        this.routes[this.index].scheduleIntros.length
        ? this.routes[this.index].scheduleIntros
        : 0
    }
  },

  onLoad(options) {
    console.log('options ===>', options)
    this.index = options.index
  }
}
</script>

<template>
  <div class="route-detail">
    <div class="content-list">
      <div
        v-for="(v,i) in item"
        :key="i"
        class="content"
      >
        <h2 v-if="v.type==='title'" class="title">{{v.content}}</h2>
        <p v-else-if="v.type==='text'" class="text">{{v.content}}</p>
        <div v-else-if="v.type==='img'" class="img-wrap">
          <img  :src="'https://source.hilval.com'+v.content" class="image" mode="aspectFill">
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.content-list {
  box-sizing: border-box;
  background-color: #fff;
}
.title {
  line-height: 2.5;
  text-align: center;
  color: #ff4d6c;
  font-size: 20px;
}
.text {
  margin: 10px;
  line-height: 1.5;
  font-size: 16px;
  color: $gray-font-color;
}

.img-wrap {
  margin: 10px;
}
.image {
  width: 100%;
  height: 300rpx;
}
</style>
